package ar.edu.sovietrussia.customcomponents.bookviews;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;

/**
 */
public class MiniBookViewPanel extends Panel {

    private static final long serialVersionUID = 1L;

    public MiniBookViewPanel(final String id, final BookModel model) {
        super(id, model);

        this.addComponents();
    }

    private void addComponents() {

        this.addLinkTitle("linkTitle");

        this.add(new Label("isbn"));

        this.add(new Label("title_label", "Title:"));
        this.add(new Label("isbn_label", "ISBN:"));
    }

    private void addLinkTitle(final String id) {
        Link<?> link = new Link<Object>(id) {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick() {
                BookModel book = (BookModel) MiniBookViewPanel.this.getDefaultModel();
                MiniBookViewPanel.this.onTitleLinkClick(book);
            }
        };

        link.add(new Label("title"));
        this.add(link);
    }

    public void onTitleLinkClick(final BookModel book) {
        // redefinir
    }

}
